<head>
  <style>
    div {
      font-family: sans-serif;
    }
    #popup {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      height: 100vh;
      width: 100vw;
      text-align: center;
    }
    #popup button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 0.375rem;
      font-size: 1.5rem;
      font-weight: 500;
      height: 2.5rem;
      padding: 0.5rem 1rem;
      background-color: black;
      color: white;
      outline: none;
      transition: background-color 150ms ease-in-out;
      margin-bottom: 20px;
    }
    #popup button:hover {
      background-color: #333;
    }
    #popup button:disabled {
      opacity: 0.5;
      pointer-events: none;
    }
    #message {
      height: 20px;
      margin-bottom: 20px;
      color: gray;
      font-size: 1.5rem;
    }
  </style>
</head>
<body>
  <div id="popup">
    <button id="popupBtn" onclick="openPopup()">${buttonText}</button>
    <div id="message">(Close this window after authorizing the app)</div>
  </div>
  <script>
    function openPopup() {
      var w = window.open("${url}", "newwindow", "popup=1");
      var m = document.getElementById("message");
      var d = document.getElementById("popupBtn");
      var timer = setInterval(function () {
        if (w.closed) {
          m.innerText = "You can close this page now";
          d.disabled = true;
          clearInterval(timer);
        }
      }, 1000);
    }
  </script>
</body>
